# -*- coding: utf-8 -*-
# @Author  : pony.guan
# @Time    : 2021/9/26
# Description: 处理机器人卡死：
#     # 1、移除机器人
#     # 2、actor/restartController           ----重启
#     # 3、/mock/oneClickCreateMockKubot          ------启动mockkubot  （需要在body中填写机器人编号）
#     # 4. http://172.20.8.56/robot-manage/robot-monitor 点击系统恢复

import json
import requests

headers = {
    "Content-Type": "application/json"
}

# 移除机器人
r1 = requests.post(
    url='http://172.20.8.56/ess-api/robot/killRobot',
    data=json.dumps({"robotCode": "kubot-1", "whetherToCancelTask": True}),
    headers=headers
)

print(r1.json()['code'])

# 重启
r2 = requests.post(
    url='http://172.20.8.56:19000/actor/restartController',
    headers=headers
)

print(r2.json()['code'])

# 启动mockkubot
r3 = requests.post(
    url='http://172.20.8.56:19000/actor/restartController',
    data=json.dumps({"kubotNum": 1, "distance": 2000}),
    headers=headers
)

print(r3.json()['code'])

# 系统恢复
r4 = requests.post(
    url='http://172.20.8.56/ess-api/system/resume',
    data=json.dumps({"zone": ""}),
    headers=headers
)
print(r4.json()['code'])
# 1、移除机器人
# 2、actor/restartController           ----重启
# 3、/mock/oneClickCreateMockKubot          ------启动mockkubot  （需要在body中填写机器人编号）
# 4. http://172.20.8.56/robot-manage/robot-monitor 点击系统恢复
